#include <iostream>
#include <unistd.h>
#include <fcntl.h>

void setNonblock(int fd)
{
    int fl = fcntl(fd, F_GETFL);
    if(fl < 0)
    {
        std::cout << "fcntl getfl fail\n";
        exit(-1);
    }
    fl |= O_NONBLOCK;
    fcntl(fd, F_SETFL, fl);
}


int main()
{
    std::cout << ">>>>>> ";
    fflush(stdout);
    char buffer[1024];
    setNonblock(0);
    // fcntl(0, F_SETFL, O_NONBLOCK);
    int ret = read(0, buffer, sizeof buffer);
    if(ret < 0)
    {
        std::cout << "read fail\n";
        exit(-1);
    }
    return 0;
}